package com.jz.community.modulemine.money.presenter;

import com.jz.community.basecomm.mvp.BaseLifeCyclePresent;
import com.jz.community.basecomm.net.rxandroid.OnLoadListener;
import com.jz.community.modulemine.money.bean.MoneyActiveBean;
import com.jz.community.modulemine.money.bean.MoneyRechargeBean;
import com.jz.community.modulemine.money.model.MoneyModel;
import com.jz.community.modulemine.money.model.MoneyModelImp;
import com.jz.community.modulemine.money.ui.MoneyRechargeView;

public class MoneyRechargePresenter extends BaseLifeCyclePresent<MoneyRechargeView.View> implements MoneyRechargeView.Presenter {

    private MoneyRechargeView.View view;
    private MoneyModel moneyModel;

    public MoneyRechargePresenter(MoneyRechargeView.View view) {
        this.view = view;
        this.moneyModel = new MoneyModelImp(view.getContext());
    }


    @Override
    public void initMoneyActive() {
        moneyModel.initMoneyActive(new OnLoadListener<MoneyActiveBean>() {
            @Override
            public void onSuccess(MoneyActiveBean moneyActiveBean) {
                view.setActiveData(moneyActiveBean);
            }

            @Override
            public void onFail(String msg, int code) {
                view.setActiveFail(msg);
            }
        });
    }

    @Override
    public void rechargeMoney(String type, double money) {
        moneyModel.reChargeMoney(type, money, new OnLoadListener<MoneyRechargeBean>() {
            @Override
            public void onSuccess(MoneyRechargeBean moneyRechargeBean) {
                view.rechargeSuccess(moneyRechargeBean);
            }

            @Override
            public void onFail(String msg, int code) {
                view.rechargeFail(msg);

            }
        });

    }
}
